package gq.example.controller;

import gq.example.entity.UsersAndRole;
import gq.example.mapper.UsersMapper;
import gq.example.result.Result;
import gq.example.service.IUsersAndRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private IUsersAndRoleService usersAndRoleService;

    @Autowired
    private UsersMapper usersMapper;

    // 修改用户角色
    @PutMapping("/updateRole")
    public Result updateRole(@RequestBody List<UsersAndRole> roles) {
        int i = usersAndRoleService.updateRolesById(roles);
        if(i > 0){
            return Result.success("修改成功");
        }

        return Result.error("服务异常");
    }
}
